package com.example.module_device.model

import com.example.module_device.R
import org.w3c.dom.Text

data class DeviceEntityItem(
    var deviceName: String,
    val deviceType: String,
    val failureRate: Double,
    val id: Int,
    val installationLocation: String,
    val status: String
){
    fun initDeviceName() : String{
        if (deviceName.isEmpty() || deviceName == ""){
            return "八维门禁"
        }else{
            return deviceName
        }
    }
    fun initDeviceType() : String{
        if (deviceType.isEmpty() || deviceType == ""){
            return "门禁设备"
        }else{
            return deviceType
        }
    }
    fun initInstallationLocation() : String{
        if (installationLocation.isEmpty() || installationLocation == ""){
            return "东门"
        }else{
            return installationLocation
        }
    }
    fun initFailureRate() : Double{
        if (failureRate <= -0.1){
            return 0.5
        }else{
            return failureRate
        }
    }
    fun initStatus() : String{
        if (status.isEmpty() || status == ""){
            return "正常"
        }else{
            return status
        }
    }
    fun statusColor() : Int{
        if (status.isNotEmpty() || status != ""){
            if (status == "正常"){
                return R.drawable.status_bg_orange
            }else if (status == "故障"){
                return R.drawable.status_bg_green
            }
        }
        return R.drawable.status_bg_orange
    }
    fun statusTextColor() : Int{
        if (status.isNotEmpty() || status != ""){
            if (status == "正常"){
                return R.color.text_orange
            }else if (status == "故障"){
                return R.color.text_green
            }
        }
        return R.color.text_orange
    }

}